<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>Global Image - Editar Venda</title>
            <link rel="stylesheet" type="text/css" href="/globalimage2/faces/jsfcrud.css" /><%@ include file="/WEB-INF/jspf/AjaxScripts.jspf" %><script type="text/javascript" src="/globalimage2/faces/jsfcrud.js"></script>
        </head>
        <body>
            <%@include file="../../WEB-INF/jspf/header/head.jspf"%>
            <div style="float:left">
                <%@include file="../../WEB-INF/jspf/header/menuDinamico.jspf"%>
            </div>
            <div id="div_content">
                <div class="bgContentTable">
                    <div class="titleTable"><h3>Editar Venda</h3></div><br />
                    <h:form>
                        &nbsp;&nbsp;<h:commandLink action="#{venda.edit}" value="Salvar">
                            <f:param name="jsfcrud.currentVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda][venda.converter].jsfcrud_invoke}"/>
                        </h:commandLink>
                        &nbsp;|&nbsp;
                        <h:commandLink action="#{venda.detailSetup}" value="Exibir" immediate="true">
                            <f:param name="jsfcrud.currentVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda][venda.converter].jsfcrud_invoke}"/>
                        </h:commandLink>
                        &nbsp;|&nbsp;
                        <h:commandLink action="#{venda.listSetup}" value="Exibir todos" immediate="true"/>
                        <h:panelGroup id="messagePanel" layout="block">
                            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                        </h:panelGroup>
                        <br />
                        <h:panelGrid columns="2" style="margin-left:10px;">
                            <h:outputText value="Cliente:"/>
                            <h:selectOneMenu id="clienteId" value="#{venda.venda.clienteId}" title="ClienteId" required="true" requiredMessage="The clienteId field is required." >
                                <f:selectItems value="#{usuario.usuarioItemsAvailableSelectOne}"/>
                            </h:selectOneMenu>
                            <h:outputText value="Vendedor:"/>
                            <h:selectOneMenu id="funcionarioId" value="#{venda.venda.funcionarioId}" title="FuncionarioId" required="true" requiredMessage="The funcionarioId field is required." >
                                <f:selectItems value="#{funcionario.funcionarioItemsAvailableSelectOne}"/>
                            </h:selectOneMenu>
                            <h:outputText value="Descrição:"/>
                            <h:inputTextarea rows="4" cols="30" id="observacao" value="#{venda.venda.observacao}" title="Observacao" />
                            <h:outputText value="Data da venda:"/>
                            <h:panelGrid columns="3">
                                <h:selectOneMenu id="diaVenda" value="#{venda.funcionarioDiaDataVenda}">
                                    <f:selectItems value="#{utilController.arrayDias}"/>
                                </h:selectOneMenu>
                                <h:selectOneMenu id="mesVenda" value="#{venda.funcionarioMesDataVenda}">
                                    <f:selectItems value="#{utilController.arrayMeses}"/>
                                </h:selectOneMenu>
                                <h:selectOneMenu id="anoVenda" value="#{venda.funcionarioAnoDataVenda}">
                                    <f:selectItems value="#{utilController.arrayAnos}"/>
                                </h:selectOneMenu>
                            </h:panelGrid>
                            <h:outputText value="Data de entrega:"/>
                            <h:panelGrid columns="3">
                                <h:selectOneMenu id="diaEntrega" value="#{venda.funcionarioDiaDataEntrega}">
                                    <f:selectItems value="#{utilController.arrayDias}"/>
                                </h:selectOneMenu>
                                <h:selectOneMenu id="mesEntrega" value="#{venda.funcionarioMesDataEntrega}">
                                    <f:selectItems value="#{utilController.arrayMeses}"/>
                                </h:selectOneMenu>
                                <h:selectOneMenu id="anoEntrega" value="#{venda.funcionarioAnoDataEntrega}">
                                    <f:selectItems value="#{utilController.arrayAnos}"/>
                                </h:selectOneMenu>
                            </h:panelGrid>
                            <h:outputText value="Data do pagamento:"/>
                            <h:panelGrid columns="3">
                                <h:selectOneMenu id="diaPagamento" value="#{venda.funcionarioDiaDataPagamento}">
                                    <f:selectItems value="#{utilController.arrayDias}"/>
                                </h:selectOneMenu>
                                <h:selectOneMenu id="mesPagamento" value="#{venda.funcionarioMesDataPagamento}">
                                    <f:selectItems value="#{utilController.arrayMeses}"/>
                                </h:selectOneMenu>
                                <h:selectOneMenu id="anoPagamento" value="#{venda.funcionarioAnoDataPagamento}">
                                    <f:selectItems value="#{utilController.arrayAnos}"/>
                                </h:selectOneMenu>
                            </h:panelGrid>
                            <h:outputText value="Transportador:"/>
                            <h:selectOneMenu id="transportadorId" value="#{venda.venda.transportadorId}" title="TransportadorId" >
                                <f:selectItems value="#{usuario.usuarioItemsAvailableSelectOne}"/>
                            </h:selectOneMenu>
                            <h:outputText value="Valor Transporte:"/>
                            <h:inputText id="valorTransporte" value="#{venda.venda.valorTransporte}" title="ValorTransporte" />
                            <h:outputText value="Seguro Transporte:"/>
                            <h:inputText id="seguroTransporte" value="#{venda.venda.seguroTransporte}" title="SeguroTransporte" />
                            <c:if test="${venda.venda.produtoVendaCollection != null}"   >
                                <h:outputText value="Produtos:"/>
                                <h:dataTable value="#{venda.venda.produtoVendaCollection}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px; width: 100%;">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Nome"/>
                                        </f:facet>
                                        <h:outputText value=" #{item.produto.nome}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Quantidade"/>
                                        </f:facet>
                                        <h:selectOneMenu value="#{item.quantidade}" title="Quantidade" >
                                            <f:selectItems value="#{utilController.array_1_to_50}"/>
                                        </h:selectOneMenu>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Preço unt"/>
                                        </f:facet>
                                        <h:inputText value="#{item.precoUnitario}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value=""/>
                                        </f:facet>
                                        <h:commandLink value="Remover" action="#{venda.removerProdutoVendaEdit}" immediate="true">
                                            <f:param name="jsfcrud.currentProduto" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][item.produto][produto.converter].jsfcrud_invoke}"/>
                                        </h:commandLink>
                                    </h:column>
                                </h:dataTable>
                            </c:if>
                        </h:panelGrid>
                        &nbsp;<h:commandLink action="#{produto.listVendaEditSetup}" value="Adicionar produto" style="margin-left:10px;"/>
                        <h:panelGrid columns="2" style="margin-left:10px;">
                            <h:outputText value="Total:"/>
                            <h:outputText value="JavaScript"/>
                        </h:panelGrid>


                        <%--
                    <h:panelGrid columns="2">
                        <h:outputText value="VendaId:"/>
                        <h:outputText value="#{venda.venda.vendaId}" title="VendaId" />
                        <h:outputText value="Observacao:"/>
                        <h:inputTextarea rows="4" cols="30" id="observacao" value="#{venda.venda.observacao}" title="Observacao" />
                        <h:outputText value="DataVenda (MM/dd/yyyy):"/>
                        <h:inputText id="dataVenda" value="#{venda.venda.dataVenda}" title="DataVenda" required="true" requiredMessage="The dataVenda field is required." >
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:inputText>
                        <h:outputText value="DataEntrega (MM/dd/yyyy):"/>
                        <h:inputText id="dataEntrega" value="#{venda.venda.dataEntrega}" title="DataEntrega" required="true" requiredMessage="The dataEntrega field is required." >
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:inputText>
                        <h:outputText value="DataPagamento (MM/dd/yyyy):"/>
                        <h:inputText id="dataPagamento" value="#{venda.venda.dataPagamento}" title="DataPagamento" required="true" requiredMessage="The dataPagamento field is required." >
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:inputText>
                        <h:outputText value="ValorTransporte:"/>
                        <h:inputText id="valorTransporte" value="#{venda.venda.valorTransporte}" title="ValorTransporte" />
                        <h:outputText value="SeguroTransporte:"/>
                        <h:inputText id="seguroTransporte" value="#{venda.venda.seguroTransporte}" title="SeguroTransporte" />
                        <h:outputText value="EntradaSaidaCollection:"/>
                        <h:selectManyListbox id="entradaSaidaCollection" value="#{venda.venda.jsfcrud_transform[jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method.collectionToArray][jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method.arrayToList].entradaSaidaCollection}" title="EntradaSaidaCollection" size="6" converter="#{entradaSaida.converter}" >
                            <f:selectItems value="#{entradaSaida.entradaSaidaItemsAvailableSelectMany}"/>
                        </h:selectManyListbox>
                        <h:outputText value="ProdutoVendaCollection:"/>
                        <h:outputText escape="false" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getCollectionAsString'][venda.venda.produtoVendaCollection == null ? jsfcrud_null : venda.venda.produtoVendaCollection].jsfcrud_invoke}" title="ProdutoVendaCollection" />
                        <h:outputText value="FuncionarioId:"/>
                        <h:selectOneMenu id="funcionarioId" value="#{venda.venda.funcionarioId}" title="FuncionarioId" required="true" requiredMessage="The funcionarioId field is required." >
                            <f:selectItems value="#{funcionario.funcionarioItemsAvailableSelectOne}"/>
                        </h:selectOneMenu>
                        <h:outputText value="ClienteId:"/>
                        <h:selectOneMenu id="clienteId" value="#{venda.venda.clienteId}" title="ClienteId" required="true" requiredMessage="The clienteId field is required." >
                            <f:selectItems value="#{usuario.usuarioItemsAvailableSelectOne}"/>
                        </h:selectOneMenu>
                        <h:outputText value="TransportadorId:"/>
                        <h:selectOneMenu id="transportadorId" value="#{venda.venda.transportadorId}" title="TransportadorId" >
                            <f:selectItems value="#{usuario.usuarioItemsAvailableSelectOne}"/>
                        </h:selectOneMenu>
                    </h:panelGrid>
                    --%>
                    </h:form>
                </div>
            </div>
        </body>
    </html>
</f:view>
